<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Class attribute</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Log v2">
<link rel="up" href="../../attributes.html#header.boost.log.attributes.attribute_hpp" title="Header &lt;boost/log/attributes/attribute.hpp&gt;">
<link rel="prev" href="../../attributes.html" title="Attributes">
<link rel="next" href="attribute/impl.html" title="Struct impl">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../attributes.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../attributes.html#header.boost.log.attributes.attribute_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="attribute/impl.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.attribute"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class attribute</span></h2>
<p>boost::log::attribute &#8212; A base class for an attribute value factory. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../attributes.html#header.boost.log.attributes.attribute_hpp" title="Header &lt;boost/log/attributes/attribute.hpp&gt;">boost/log/attributes/attribute.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// member classes/structs/unions</span>

  <span class="comment">// A base class for an attribute value factory.</span>

  <span class="keyword">struct</span> <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive_ref_counter</span><span class="special">&lt;</span> <span class="identifier">impl</span> <span class="special">&gt;</span> <span class="special">{</span>
    <span class="comment">// <a class="link" href="attribute/impl.html#boost.log.attribute.implconstruct-copy-destruct">construct/copy/destruct</a></span>
    <a class="link" href="attribute/impl.html#idp32779952-bb"><span class="special">~</span><span class="identifier">impl</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

    <span class="comment">// <a class="link" href="attribute/impl.html#idp20173424-bb">public member functions</a></span>
    <span class="keyword">virtual</span> <a class="link" href="attribute_value.html" title="Class attribute_value">attribute_value</a> <a class="link" href="attribute/impl.html#idp20173984-bb"><span class="identifier">get_value</span></a><span class="special">(</span><span class="special">)</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>

    <span class="comment">// <a class="link" href="attribute/impl.html#idp32780528-bb">public static functions</a></span>
    <span class="keyword">static</span> <span class="keyword">void</span> <span class="special">*</span> <a class="link" href="attribute/impl.html#idp32781088-bb"><span class="keyword">operator</span> <span class="keyword">new</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">)</span><span class="special">;</span>
    <span class="keyword">static</span> <span class="keyword">void</span> <a class="link" href="attribute/impl.html#idp32782896-bb"><span class="keyword">operator</span> <span class="keyword">delete</span></a><span class="special">(</span><span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="special">}</span><span class="special">;</span>
  <span class="comment">// <a class="link" href="attribute.html#boost.log.attributeconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="attribute.html#idp32794720-bb"><span class="identifier">attribute</span></a><span class="special">(</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">default</span><span class="special">;</span>
  <a class="link" href="attribute.html#idp32539344-bb"><span class="identifier">attribute</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="attribute.html#idp32541296-bb"><span class="identifier">attribute</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">explicit</span> <a class="link" href="attribute.html#idp32543248-bb"><span class="identifier">attribute</span></a><span class="special">(</span><span class="identifier">intrusive_ptr</span><span class="special">&lt;</span> <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">&gt;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span> <a class="link" href="attribute.html#idp32546768-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span> <a class="link" href="attribute.html#idp32549296-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="attribute.html#idp32785824-bb">public member functions</a></span>
  <span class="keyword">explicit</span> <a class="link" href="attribute.html#idp32786384-bb"><span class="keyword">operator</span> <span class="keyword">bool</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="attribute.html#idp32788336-bb"><span class="keyword">operator</span><span class="special">!</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="attribute_value.html" title="Class attribute_value">attribute_value</a> <a class="link" href="attribute.html#idp32789904-bb"><span class="identifier">get_value</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="attribute.html#idp32792080-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="attribute.html#idp32551824-bb">protected member functions</a></span>
  <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">*</span> <a class="link" href="attribute.html#idp32552400-bb"><span class="identifier">get_impl</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="attribute.html#idp32554656-bb"><span class="identifier">set_impl</span></a><span class="special">(</span><span class="identifier">intrusive_ptr</span><span class="special">&lt;</span> <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">&gt;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="attribute.html#idp34013072-bb">friend functions</a></span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">friend</span> <span class="identifier">T</span> <a class="link" href="attribute.html#idp34013632-bb"><span class="identifier">attribute_cast</span></a><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp117618832"></a><h2>Description</h2>
<p>Every attribute is represented with a factory that is basically an attribute value generator. The sole purpose of an attribute is to return an actual value when requested. A simplest attribute can always return the same value that it stores internally, but more complex ones can perform a considerable amount of work to return a value, and the returned values may differ each time requested.</p>
<p>A word about thread safety. An attribute should be prepared to be requested a value from multiple threads concurrently. </p>
<div class="refsect2">
<a name="idp117620304"></a><h3>
<a name="boost.log.attributeconstruct-copy-destruct"></a><code class="computeroutput">attribute</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idp32794720-bb"></a><span class="identifier">attribute</span><span class="special">(</span><span class="special">)</span> <span class="special">=</span> <span class="keyword">default</span><span class="special">;</span></pre>
<p>Default constructor. Creates an empty attribute value factory, which is not usable until <code class="computeroutput">set_impl</code> is called. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp32539344-bb"></a><span class="identifier">attribute</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Copy constructor </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idp32541296-bb"></a><span class="identifier">attribute</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Move constructor </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idp32543248-bb"></a><span class="identifier">attribute</span><span class="special">(</span><span class="identifier">intrusive_ptr</span><span class="special">&lt;</span> <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">&gt;</span> p<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Initializing constructor</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">p</code></span></p></td>
<td><p>Pointer to the implementation. Must not be <code class="computeroutput">NULL</code>. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span> <a name="idp32546768-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Copy assignment </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span> <a name="idp32549296-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Move assignment </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp117670544"></a><h3>
<a name="idp32785824-bb"></a><code class="computeroutput">attribute</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idp32786384-bb"></a><span class="keyword">operator</span> <span class="keyword">bool</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Verifies that the factory is not in empty state </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idp32788336-bb"></a><span class="keyword">operator</span><span class="special">!</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Verifies that the factory is in empty state </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="attribute_value.html" title="Class attribute_value">attribute_value</a> <a name="idp32789904-bb"></a><span class="identifier">get_value</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The actual attribute value. It shall not return empty values (exceptions shall be used to indicate errors). </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp32792080-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="special">&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>The method swaps two factories (i.e. their implementations). </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp117699728"></a><h3>
<a name="idp32551824-bb"></a><code class="computeroutput">attribute</code> protected member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">*</span> <a name="idp32552400-bb"></a><span class="identifier">get_impl</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The pointer to the implementation </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idp32554656-bb"></a><span class="identifier">set_impl</span><span class="special">(</span><span class="identifier">intrusive_ptr</span><span class="special">&lt;</span> <a class="link" href="attribute/impl.html" title="Struct impl">impl</a> <span class="special">&gt;</span> p<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Sets the pointer to the factory implementation.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">p</code></span></p></td>
<td><p>Pointer to the implementation. Must not be <code class="computeroutput">NULL</code>. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idp117722048"></a><h3>
<a name="idp34013072-bb"></a><code class="computeroutput">attribute</code> friend functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> <span class="keyword">friend</span> <span class="identifier">T</span> <a name="idp34013632-bb"></a><span class="identifier">attribute_cast</span><span class="special">(</span><a class="link" href="attribute.html" title="Class attribute">attribute</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span></pre>
<p>The function casts one attribute factory to another </p>
</li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2007-2014 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../attributes.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../attributes.html#header.boost.log.attributes.attribute_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="attribute/impl.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
